#include using namespace std; const int MATRIX_SIZE = 4; void getMatrixFromUser(int matrixIndex, int matrix[][MATRIX_SIZE]); void addMatrices(int matrix1[][MATRIX_SIZE], int matrix2[][MATRIX_SIZE], int result[][MATRIX_SIZE]); void main() { int matrices[25][MATRIX_SIZE][MATRIX_SIZE]; int initialMatrices; int matricesUsed = 0; cout << "How many initial matrices?"; cin >> initialMatrices; while(matricesUsed < initialMatrices) { getMatrixFromUser(matricesUsed + 1, matrices[matricesUsed]); matricesUsed++; } char operation; int firstMatrixIndex; int secondMatrixIndex; //get operation until 'Q' or 'q' is entered cout << "Operation? "; cin >> operation; switch(operation) { case '+': //call function to add cout << "First matrix for +?"; //add logic to make sure that the index entered is in the range 1- matricesUsed cin >> firstMatrixIndex; cout << "Second matrix for +?"; cin >> secondMatrixIndex; addMatrices(matrices[firstMatrixIndex], matrices[secondMatrixIndex], matrices[matricesUsed]); matricesUsed++; break; case '-': //call function to add break; case '*': //call function to add break; case 'X': case 'x': //call function to add break; case 't': case 'T': //call function to add break; case 'D': case 'd': //call function to add break; } } void getMatrixFromUser(int matrixIndex, int matrix[][MATRIX_SIZE]) { cout << "Enter matrix " << matrixIndex << ":\n"; for(int row = 0; row < MATRIX_SIZE; row++) { cout << "Row " << row + 1 << "? "; for(int column = 0; column < MATRIX_SIZE; column++) { cin >> matrix[row][column]; } } } void addMatrices(int matrix1[][MATRIX_SIZE], int matrix2[][MATRIX_SIZE], int result[][MATRIX_SIZE]) { for(int row = 0; row < MATRIX_SIZE; row++) { for(int column = 0; column < MATRIX_SIZE; column++) { result[row][column] = matrix1[row][column] + matrix2[row][column]; } } }